// purchase/sping/sping.js
var o;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopping:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    o = this;
    getApp().page.onLoad(o, e);
    var shopping = wx.getStorageSync('shopping')
    for(var i=0; i<shopping.length; i++){
      for(var j=i+1; j<shopping.length; j++){
          if(shopping[i].id==shopping[j].id){         //第一个等同于第二个，splice方法删除第二个
            shopping.splice(j,1);
              j--;
          }
      }
  }
  wx.setStorageSync('shopping',shopping)
    o.setData({
      shopping:shopping
    })
    wx.setNavigationBarTitle({
      title: '购物车'
    })
  },
  goodsInfo: function (t) {
    console.log(t.currentTarget.dataset)
    var e = t.currentTarget.dataset.id,inde = t.currentTarget.dataset.inde;
    wx.setStorageSync('inde',inde)
    getApp().core.navigateTo({
      url: "/purchase/goods_info/goods_info?id=" + e + '&gw=1'
    });
  },
  ind:function(e){
    wx.reLaunch({
      url: '/purchase/index/index',
    })
  },
  order:function(e){
    wx.reLaunch({
      url: '/purchase/order/order',
    })
  }
})